package com.tony.blog.server.lucene;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: MyIKAnalyzer
 * @Auther: 皮蛋布丁
 * @Date: 2021/09/28/9:34
 * @Description: 解决高版本lucene不匹配IKAnalyzer(由于IKanalyzer版本一直未更新)
 */
public class MyIKAnalyzer extends Analyzer {

    private boolean useSmart;

    public boolean useSmart() {
        return this.useSmart;
    }

    public void setUseSmart(boolean useSmart) {
        this.useSmart = useSmart;
    }

    public MyIKAnalyzer() {
        this(false);
    }

    @Override
    protected TokenStreamComponents createComponents(String s) {
        Tokenizer _MyIKTokenizer = new MyIKTokenizer(this.useSmart());
        return new TokenStreamComponents(_MyIKTokenizer);
    }

    public MyIKAnalyzer(boolean useSmart) {
        this.useSmart = useSmart;
    }
}
